<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!-- 导入头部head，js内容 -->
<%--<jsp:include page="include_javascript_head.jsp"/>--%>
<!-- 导入头部标题栏内容 -->

<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
    String basePath2 = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path ;
    request.setAttribute("basePath", basePath) ;
    request.setAttribute("basePath2", basePath2) ;


%>
<base href="<%=basePath%>">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.../TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.../1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>demo</title>
	<link rel="stylesheet" href="css/bootstrap.min.css" />
	<link rel="stylesheet" href="css/common.css" />
	<link rel="stylesheet" href="css/welcome.css" />
	<link rel="stylesheet" href="css/jquery.ptTimeSelect.css" /><!-- 日历样式 -->
	<script type="text/javascript" src="js/jquery-1.8.3.min.js" ></script>
	<script type="text/javascript" src="js/common.js"></script>
</head>
<body>
<!-- 弹框开始  -->
<div class="zhy_zhezhao_pop" style="display: none;"></div>
<!--实名认证用户没有权限-->
<div class="zhy_popa create_site_1 " style="width: 450px;margin-left: -225px;">
	<p class="color66">温馨提示<span class="pull-right close_icon" onclick="hidePop()"></span></p>
	<div class="pop_content text-center">
		<p>尊敬的${accountName}，您的服务站创建权限已用完 </p>
		<p>如需创建更多的服务站，请前往“应用市场”->“购买管理”中购买</p>
		<div class="operate_btn pull-right">
			<a class="btn cancle_yes" href="/cloud-portal/order/add_licence_max?moduleCode=multisite" >立即购买</a>
			<button type="button" class="btn cancel" onclick="hidePop()">关闭</button>
		</div>
	</div>
</div>

<div class="zhy_popa zhy_popa_cancel" style="width: 450px;margin-left: -225px;display: none;">
	<p class="color66">提示<span class="pull-right close_icon" onclick="hidePopC()"></span></p>
	<div class="pop_content">
		<p>确定要删除所选数据吗?</p>
		<div class="operate_btn pull-right">
			<button type="button" class="btn cancle_yes">确定</button>
			<button type="button" class="btn cancle_btn" onclick="hidePopC()">取消</button>
		</div>
	</div>
</div>
<!--没有实名认证用户-->
<div class="zhy_popa create_site_2 " style="width: 450px;margin-left: -225px;">
	<p class="color66">温馨提示<span class="pull-right close_icon" onclick="hidePop()"></span></p>
	<div class="pop_content text-center">
		<p>尊敬的${accountName}，您暂时没有创建服务站的权限 </p>
		<p>如需创建服务站，请及时进行实名认证</p>
		<div class="operate_btn pull-right">
			<button type="button" class="btn cancle_yes" >立即认证</button>
			<button type="button" class="btn cancel" onclick="hidePop()">关闭</button>
		</div>
	</div>
</div>
<!--弹框结束-->

<div class="main_content " >
	<div class="col-xs-12 col-sm-12 ">
		<div class="site_toggle_title">
			<%--<div class="nav_head ">
					<li class="on">搜索</li>
					<form action="">
						<input id="province" type="text" list="url_list" name="text" />
						<input type="submit" />
					</form>
					<datalist id="url_list">
						<c:forEach items="${allProvince}" var="li" >
							<option label="提示1" value="${li.province}" />
						</c:forEach>
					</datalist>
				</ul>
			</div>--%>
			<div class="nav_head ">
				<ul>
					<!--<li class="" onclick="window.location.href='/cloud-statistics/station/displaypage/main'"  >服务站总览</li>-->
					<li class="on">服务站列表</li>
				</ul>
			</div>
			<div style="height: 20px; background: #edf0f2;"></div>
		</div>
		<div id="msg" >
			<h1 style="color: red"> ${msg}</h1>
		</div>
		<div class="list_page div_bordered" >
			<div class="panel panel-default" >
				<!-- Default panel contents -->
				<div class="panel-heading" >
					<form class="form-inline pl20" role="form">
						<div class="form-group" >
							<div id="jsAddress_0"  class="selectbox_s">
								<input type="hidden" class="province" value="-1"/>
								<input type="hidden" class="city" value="-1"/>
								<input type="hidden" class="area" value="-1"/>
								<span class="" for="">省份：</span>
								<div name="province1" type=""  class="btn-group inline ">
									<span class="" for="">省份：
									<select  id="province1" style="width:118px;margin-left:-100px" onchange=" ">
									<option value="">省份 </option>
									<c:forEach items="${allProvince}" var="li">
										<option  value="${li.province}">${li.province} </option>
									</c:forEach>
								</select>
								</div>
								<span class="" for="">省份：</span>

									<span class="" for="">省份：
										<select id="city1"  style="width:118px;margin-left:-100px" onchange="">
										    <option  value="">城市 </option>
										</select>
									</span>
								<span class="" for="">省份：</span>

									<span class="" for="">省份：
                                        <select id="area1" style="width:118px;margin-left:-100px" onchange="">
									        <option value="">地区</option>

								        </select>
						</div>
						<button type="button" class="btn btn_shanxuan" id="queryButton">搜索</button>
						<div class="pull-right text-right mr15">
								<span class="colorblue ">
									<a class="btn_blueg2" onclick="addStPreEvt()" href="add_pre">+创建服务站</a>
								</span>
						</div>
					</form>
				</div>
				<!-- 总条数，分页使用 -->
				<table class="table table-bordered  table-hover ">
					<tHead>
					<tr>
						<th width="18%">服务站</th>
						<th width="15%">省份</th>
						<th width="15%">城市</th>
						<th width="15%">区县</th>
						<th>操作</th>
					</tr>
					</tHead>
					<tBody id="flushDIV">

					<c:forEach items="${allSs}" var="li" >
						<tr>
							<td>${li.serviceStationName}</td>
							<td>${li.provinceName}</td>
							<td>${li.cityName}</td>
							<td>${li.areaName}</td>
							<td>
								<span><a href="detail?id=${li.id}" class="colorblue">详情</a></span>
								<span><a href="edit_pre?id=${li.id}" class="colorblue">修改</a></span>
								<span><a href="del?id=${li.id}" class="colorred delete">删除</a></span>
							</td>
						</tr>
					</c:forEach>
					</tBody>

				</table>
			</div>

			<div class="row text-center">
				<div id="Pagination" class="pagination">
					<jsp:include page="split_plugin_page_bar_notime.jsp"/>
				</div>
			</div>



		</div>

	</div>

</div>
<!-- 省市区联动 s -->
<script type="text/javascript" src="js/jquery.ganged.js" ></script>
<script type="text/javascript" src="js/pro.js"></script><!--  省市区的json数据 -->
<script type="text/javascript" src="js/jquery.pagination.js"></script>

<script>

        $("#province1").bind("change",function(){
            //获取被选中的option的值
            var miaoshu = $(this).val();
            //获取自定义属性的值
            var province = $(this).find("option:selected").val();
            $.ajax({
                type: 'POST',
                url: "<%=basePath2%>/city",
                data: {
                    province:province,
                },
                dataType: "json",
                success:function(data){
                    if(data!=null){
                        $("#city1").empty();
                        var $tr1 =$('<option  value=>城市</option>');
                        $("#city1").append($tr1);
                        for(var i=0;i<data.length;i++){

                            var $tr2 =$('<option  value='+data[i].city+'>'+data[i].city+ '</option>');
                            $("#city1").append($tr2);
                        }
                    }else{
                        $("#flushDIV").html('<tr><td colspan="5" style="text-align: center">暂无数据</td></tr>');
                        $("#Pagination").empty();
                    }
                }
            });
        })
        $("#city1").bind("change",function(){
            //获取被选中的option的值
			//获取自定义属性的值
            var province = $("#province1").find("option:selected").val();
            var city = $("#city1").find("option:selected").val();
            $.ajax({
                type: 'POST',
                url: "<%=basePath2%>/area",
                data: {
                    province:province,
                    city:city
                },
                dataType: "json",
                success:function(data){

                    if(data!=null){

                        $("#area1").empty();
                        var $tr1 =$('<option  value=>地区</option>');
                        $("#area1").append($tr1);
                        for(var i=0;i<data.length;i++){
                            var $tr1 =$('<option  value=地区></option>');
                            var $tr2 =$('<option  value='+data[i].area+'>'+data[i].area+ '</option>');
                            $("#area1").append($tr2);
                        }
                    }else{
                        $("#flushDIV").html('<tr><td colspan="5" style="text-align: center">暂无数据</td></tr>');
                        $("#Pagination").empty();
                    }
                }
            });

        });


</script>










<script>

var hasStation='${hasStation}';
    var maxStation='${businessStatus.stationCount}';
    //创建服务站事件
    function addStPreEvt(){

        window.location.href = "/cloud-portal/station/addpre";
    }
    //在子页面显示弹框
    function showPopC(obj,className,id){
        $(".zhy_zhezhao_pop").show();
        var top = document.body.scrollTop||document.documentElement.scrollTop;
        var this_h = $("." + className).height();
        var win_h = ($('html',parent.document).height()-this_h-100)/2
        $(".zhy_zhezhao_pop").height($("html").height());
        var this_h = $("." + className).height();
        top= top +win_h;
        $("." + className).css("top", top).show().siblings(".zhy_popa").hide();
    }
    // 隐藏修改弹框
    function hidePop() {
        $(".zhy_zhezhao_pop").hide();
        $(".zhy_popa").hide();
    }
    //省市区联动 调用
    $('#jsAddress_0').ganged({'data': provinceList, 'width': 111, 'height': 32});

    //////////////////////////////////////////////////////////////
    function showStationChange(className,obj){
        showPopStation(obj,className);

        InitTable(0);
    }

    function initPage(pageIndex,pageSize,total){
        //分页，PageCount是总条目数，这是必选参数，其它参数都是可选
        $("#Pagination").pagination(total, {
            callback: function(){return true;},
            link_to:"javascript:InitTable(__id__)",
            prev_text: '上一页',       //上一页按钮里text
            next_text: '下一页',       //下一页按钮里text
            items_per_page: pageSize,  //显示条数
            num_display_entries: 6,    //连续分页主体部分分页条目数
            current_page: pageIndex-1,   //当前页索引
            num_edge_entries: 2        //两侧首尾分页条目数
        });

    }
    //请求数据
    function InitTable(pageIndex) {

        var province = $("#province1 option:selected").text()
        var city = $("#city1 option:selected").text()
        var area = $("#area1 option:selected").text()
        pageIndex = parseInt(pageIndex)+1;


        $.ajax({
            type: 'POST',
            url: "<%=basePath2%>/search",
            data: {
                province:province,
                city:city,
                area:area,
                page:pageIndex,
                pageSize:10
            },
            dataType: "json",
            success:function(data){

                var stations=data.allStations;

                if(stations!=null){
                    $("#flushDIV").empty();
                    for(var i=0;i<stations.length;i++){
                        var $tr =$('<tr><td >'+stations[i].serviceStationName+'</td>'
                            +'<td >'+stations[i].provinceName+'</td>'
                            +'<td >'+stations[i].cityName+'</td>'
                            +'<td >'+stations[i].areaName+'</td>'
                            +'<td><span><a href="edit_pre?id='+stations[i].serviceStationCode+'" class="colorblue">修改</a></span></td>'
                            +'</tr>');
                        $("#flushDIV").append($tr)
                    }
                    initPage(data.pageNum,data.pageSize,data.totalCount);
                }else{
                    $("#flushDIV").html('<tr><td colspan="5" style="text-align: center">暂无数据</td></tr>');
                    $("#Pagination").empty();
                }

            }
        });
    }
    //InitTable(0);

    //搜索框
    $("#queryButton").click(function(){

        InitTable();
    });

</script>

</body>



